package cn.design.realize;

import java.util.List;

/**
 * @author dlq
 * @description Person  深克隆实现的一个 Bean 类
 * @date 2020/9/14 10:11
 */
public class Person implements Cloneable {
    private Integer id;

    private String name;

    private List<String> interest;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<String> getInterest() {
        return interest;
    }

    public void setInterest(List<String> interest) {
        this.interest = interest;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", interest=" + interest +
                '}';
    }

    /**
     * 1. 将作用域protect 改成 public，否则 外部无法调用
     * 2.这里为了消除强转，这里直接使用一个具体返回的类型
     */
    @Override
    public Person clone() throws CloneNotSupportedException {
        return (Person) super.clone();
    }
}
